package hust.rpc.handler;

import hust.rpc.pojo.Message;
import hust.rpc.pojo.RpcRequest;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;

@Slf4j
public class TestHandler extends SimpleChannelInboundHandler<Message> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Message msg) throws Exception {
        RpcRequest rpcRequest = (RpcRequest) msg.getData();
        List<Map<String, String>> services = (List<Map<String, String>>) rpcRequest.getArgs()[0];
        log.info("从{}收到消息 -> {}", ctx.channel(), msg);
        log.info(String.valueOf(services));
    }
}
